/**
    入驻小区
**/
(function(vc){
    var DEFAULT_PAGE = 1;
    var DEFAULT_ROWS = 10;
    vc.extends({
        data:{
            affiliateUserManageInfo:{
                affiliateUsers:[],
                total:0,
                records:1,
                moreCondition:false,
                auId:'',
                conditions:{
                    userName:'',
                    level:'',
                }
            }
        },
        _initMethod:function(){
            vc.component._listAffiliateUsers(DEFAULT_PAGE, DEFAULT_ROWS);
        },
        _initEvent:function(){

            vc.on('affiliateUserManage','listAffiliateUser',function(_param){
                  vc.component._listAffiliateUsers(DEFAULT_PAGE, DEFAULT_ROWS);
            });
             vc.on('pagination','page_event',function(_currentPage){
                vc.component._listAffiliateUsers(_currentPage,DEFAULT_ROWS);
            });
        },
        methods:{
            _listAffiliateUsers:function(_page, _rows){

                vc.component.affiliateUserManageInfo.conditions.page = _page;
                vc.component.affiliateUserManageInfo.conditions.row = _rows;
                var param = {
                    params:vc.component.affiliateUserManageInfo.conditions
               };

               //发送get请求
               vc.http.apiGet('affiliateUser.listAffiliateUser',
                             param,
                             function(json,res){
                                var _affiliateUserManageInfo=JSON.parse(json);
                                vc.component.affiliateUserManageInfo.total = _affiliateUserManageInfo.total;
                                vc.component.affiliateUserManageInfo.records = _affiliateUserManageInfo.records;
                                vc.component.affiliateUserManageInfo.affiliateUsers = _affiliateUserManageInfo.data;
                                vc.emit('pagination','init',{
                                     total:vc.component.affiliateUserManageInfo.records,
                                     currentPage:_page
                                 });
                             },function(errInfo,error){
                                console.log('请求失败处理');
                             }
                           );
            },
            _openAddAffiliateUserModal:function(){
                vc.emit('addAffiliateUser','openAddAffiliateUserModal',{});
            },
            _openEditAffiliateUserModel:function(_affiliateUser){
                vc.emit('editAffiliateUser','openEditAffiliateUserModal',_affiliateUser);
            },
            _openDeleteAffiliateUserModel:function(_affiliateUser){
                vc.emit('deleteAffiliateUser','openDeleteAffiliateUserModal',_affiliateUser);
            },
            _queryAffiliateUserMethod:function(){
                vc.component._listAffiliateUsers(DEFAULT_PAGE, DEFAULT_ROWS);

            },
            _moreCondition:function(){
                if(vc.component.affiliateUserManageInfo.moreCondition){
                    vc.component.affiliateUserManageInfo.moreCondition = false;
                }else{
                    vc.component.affiliateUserManageInfo.moreCondition = true;
                }
            },
            _level: function (_state) {
                if(_state == "1"){
                    return "一级"
                }
                if(_state == "2"){
                    return "二级"
                }
            },
            _auditState: function (_state) {
                if(_state == "0"){
                    return "待审核"
                }
                if(_state == "1"){
                    return "审核通过"
                }
                if(_state == "2"){
                    return "已拒绝"
                }
            },
            _toDetail:function(_affiliateUser){
                vc.jumpToPage('/#/pages/affiliate/affiliateUserDetail?auId='+_affiliateUser.auId);
            }



        }
    });
})(window.vc);
